package com.example.imagedemo.slice;

import com.example.imagedemo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Image;
import ohos.agp.components.element.Element;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        // 获取Image实例对象
        Image image = (Image)findComponentById(ResourceTable.Id_image);
        // 设置缩放模式
        image.setScaleMode(Image.ScaleMode.STRETCH);
        image.setClipAlignment(Image.GRAVITY_BOTTOM);
        // 设置本地图片资源的id
        image.setPixelMap(ResourceTable.Media_avatar);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
